const fs = require('fs');
const path = require('path');
import {getCurrentTime,isDevelopment} from "./index";

export function logger(arg:any,title='') {
    if(isDevelopment()){
        console.log(title+':',arg)
    }else {
        const writeStream = fs.createWriteStream(path.join(__dirname, 'app.log'), { flags: 'a' });
        writeStream.write(getCurrentTime() +'::' + title+':'+JSON.stringify(arg) + '\n');
        writeStream.end();
    }
}